#include "PhysicsListMessenger.hh"

#include "G4LossTableManager.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIdirectory.hh"
#include "PhysicsList.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys) : _fPhysicsList(pPhys)
{
    _fPhysDir = new G4UIdirectory("/testem/phys/", true);
    _fPhysDir->SetGuidance("physics list commands");

    _fListCmd = new G4UIcmdWithAString("/testem/phys/addPhysics", this);
    _fListCmd->SetToBeBroadcasted(true);
    _fListCmd->SetGuidance("Add modula physics list.");
    _fListCmd->SetParameterName("PList", false);
    _fListCmd->AvailableForStates(G4State_PreInit);

    _fVerbCmd = new G4UIcmdWithAnInteger("/testem/phys/verbose", this);
    _fVerbCmd->SetGuidance("Set verbose level for processes");
    _fVerbCmd->SetParameterName("pVerb", false);
    _fVerbCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

PhysicsListMessenger::~PhysicsListMessenger()
{
    delete _fListCmd;
    delete _fVerbCmd;
    delete _fPhysDir;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
{
    if (command == _fVerbCmd)
    {
        G4LossTableManager::Instance()->SetVerbose(_fVerbCmd->GetNewIntValue(newValue));
    }

    if (command == _fListCmd)
    {
        _fPhysicsList->AddPhysicsList(newValue);
    }
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......